//
//  CXSearchTableViewCell.m
//  ProjectOfBStage
//
//  Created by cuixin on 15/11/16.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "CXSearchTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation CXSearchTableViewCell

-(void)dealloc{
    [_imgView release];
    [_titleLabel release];
    [_infoLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        self.titleLabel = [[UILabel alloc ]init];
        self.infoLabel = [[UILabel alloc] init];
        
        self.titleLabel.font = [UIFont systemFontOfSize:HEIGHT_PRO(15)];
        self.infoLabel.font = [UIFont systemFontOfSize:HEIGHT_PRO(13)];
        
        
        [self.contentView addSubview:self.imgView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.infoLabel];
        
        [_imgView release];
        [_titleLabel release];
        [_infoLabel release];
        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.imgView.frame = CGRectMake(WIDTH_PRO(5), HEIGHT_PRO(5), WIDTH_PRO(150), HEIGHT_PRO(100));
    self.titleLabel.frame = CGRectMake(self.imgView.frame.origin.x + self.imgView.frame.size.width + WIDTH_PRO(10), self.imgView.frame.origin.y + HEIGHT_PRO(10), self.frame.size.width - self.imgView.frame.size.width - self.imgView.frame.origin.x, HEIGHT_PRO(30));
    self.infoLabel.frame = CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y + HEIGHT_PRO(10), self.titleLabel.frame.size.width, self.titleLabel.frame.size.height);
}

-(void)setSearchModel:(CXSearchModel *)searchModel{
    if (_searchModel != searchModel) {
        [_searchModel release];
        _searchModel = [searchModel retain];
    }
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:searchModel.pic] placeholderImage:[UIImage imageNamed:@"wait.png"]];
    self.titleLabel.text = searchModel.name;
    self.infoLabel.text = searchModel.info;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
